package cn.serein.charging.order.controller;


import cn.serein.charging.common.pojo.JsonResult;
import cn.serein.charging.order.pojo.param.OrderAddParam;
import cn.serein.charging.order.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/order")
@Api(tags = "订单接口")
public class OrderController {

    // 自动装配
    @Autowired
    private OrderService orderService;

    @PostMapping("/create")
    @ApiOperation(value = "创建订单")
    public JsonResult<String> createOrder(@RequestBody OrderAddParam orderAddParam) {

        String orderNO = orderService.createOrder(orderAddParam);
//        JsonResult<String> result = new JsonResult<>();
//        result.setCode(2000);
//        result.setMessage("创建订单成功");
//        result.setData(orderNO);

        return JsonResult.success(2000, "创建订单成功", orderNO);
    }

}
